Skip to content

perf(shader): reuse certified finite conditions in arithmetic regions - #17709

Merged
oneandonlydean merged 13 commits into
boykopovar:mainfrom
Filip722:perf/certified-finite-conditions-20261109
Nov 17, 2026
Merged

oneandonlydean merged 13 commits into
boykopovar:mainfrom
Filip722:perf/certified-finite-conditions-20261109

Conversation

@Filip722

@Filip722 Filip722 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What

The arithmetic-region guard in #17681 proves finite bounds for its speculative intermediates, but the emitted fast path still evaluates combined NaN/Infinity selections whose conditions that certificate already rules out. Reusing those proved facts removes more repair work without changing the guard or exact fallback.

  • Query only finite bounds already recorded by the successful certificate; this lookup cannot add unguarded inputs or change the threshold.
  • Prove conjunctions false when either operand is false, and disjunctions only when both are false. Use that result to take the false arm of additional scalar selections in the certified path.
  • Extend the existing emission fixture: the combined NaN/Infinity selection remains only in the exact fallback; a finite-equals-one condition keeps both selections.

The extra proof covers the speculative values computed under the existing entry guard. Each new replacement has a false condition there; induction in SSA order preserves the same fast values. The exact region, all-definition merge, arithmetic lowering, NaN source priority/payload/quieting, invalid-result canonicalization, FTZ, tiny-product handling, signed zero and modifiers are unchanged. A failed certificate/guard still executes the existing path. No native NaN-propagation or ordinary-input assumption is added.

The two matched programs expose 72 and five additional selections. In the associated production GPL/LTO fragment, native instructions fall from 8,541 to 8,245 and conditional moves from 1,165 to 1,108. Allocation remains 48 VGPRs and 128 SGPRs, with no scratch spills and the same theoretical occupancy. These counts establish changed work, not removable GPU time.

This is a dependent follow-up to #17681; its prerequisite commits are included until that PR merges. The original incremental patch is commit 9ece702ba44b; the current integration also carries the prerequisite traversal repair and indexed-definition API adaptation. The overlap tool checked 1,952 open PRs. Flagged shared-file branches retain the already-reviewed ballot/BDA/stencil changes; the new #17691 conflict deletes all three shared files rather than adding a competing implementation. No duplicate finite-condition certificate reuse was found.

Tested

Author follow-up (2026-11-15), head b0e569cdbef8, with pinned main fd58fa5a0213 integrated before all tests and captures. Adapted EmitNanRegion to main’s indexed definition table using the existing Erase/Emplace operations; the previous map assignment no longer built. The repaired traversal and original exact fallback remain intact.

Matched hardware validation passes 15 focused tests on each side on AMD Radeon 760M / RADV Mesa 25.0.7 / Debian 13 / Linux 7.3.3 and the NVIDIA GeForce RTX 5060 Laptop GPU / NVIDIA 615.78.08 / Bazzite 44 / Linux 7.2.9. Khronos 1.4.363 is actually inserted in every device fixture; no skipped GPU tests, missing-layer messages or VUID errors. These are author runs, distinct from the contributor reports below.

Current-head NVIDIA capture: ProsperoLight PPSA99002 01.000.110, the same fresh no-PC idle scene, 3840×2160 source buffers and 1920×1080 X11 output, GCC 15.2 Release/SPIRV-Tools ON. Two fixed warmed 10-second windows per head, with shared main controls in forward/reverse order; all ten valid windows are retained; two objectively unusable outage attempts were replaced, with no extra pairs. GPU command span/present: main 5.720 / 6.032 ms; this full PR head 6.185 / 6.170 ms. Paired reduction: -8.129% / -2.288%, mean -5.209%, 95% Student-t df1 interval [-42.321%, +31.904%] (inconclusive). This is GPU command-span efficiency at the 60 Hz cap, not an FPS increase. The #17681/#17709/#17919 comparisons measure their full prerequisite stacks, not isolated incremental gains. One stationary scene and two pairs limit scope and precision.

Cold diagnostics still show a cost relative to pinned main: maximum reported per-draw pipeline phase is 1,218.1 / 1,161.3 ms on main, 1,743.4 / 1,735.3 ms on #17681, and 1,741.0 / 1,743.4 ms on #17709. This is APS5_PROFILE_DRAW’s longest pipeline phase, not an isolated vkCreateGraphicsPipelines timer. Separate empty-cache diagnostics use two runs per arm; these data do not reproduce the extra #17709-over-#17681 cold penalty seen in the older Windows report, but the shared main-to-region penalty remains material and is not marked resolved. The same retained 5,413-code-word fragment emits 210,144 / 271,375 / 270,665 SPIR-V words on main / #17681 / #17709. All 50 replayed modules (10 requests per arm) pass SPIR-V validation.

Audited current-head traces, raw summary lines, trace_digest.py outputs, protocol, exact binary provenance, cold diagnostics, numeric replay counts and hardware validation. Traces contain only host timing/count data. Game files, shaders, screenshots, caches and console logs remain private. After an abrupt laptop outage, six usable original captures were retained; the seventh had zero-length recovered files and the eighth had no completed trace. Only those two were replaced, and the remaining planned windows finished after a qualified restart. The driver, binaries and scene were unchanged. Earlier excluded warmup deadline failures are also disclosed. Author work and reviewer acceptance are separate.

Current main and current-head capture summary lines (first window; all windows and digests attached)
{"commit":"fd58fa5a0213","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10"},"gpu":"NVIDIA GeForce RTX 5060 Laptop GPU","driver":"NVIDIA 615.78.08","os":"Linux 7.2.9-ogc2.1.fc44.x86_64","cpu":"Intel(R) Core(TM) 7 240H","cpu_threads":16,"memory_mib":15672,"title_id":"PPSA99002","title":"ProsperoLight","content_version":"01.000.110","resolution":"3840x2160","window":{"spec":"seconds 15:10","first_present":895,"ms":10016.296},"presents":600,"frame_ms":{"p50":16.688,"p90":18.355,"p99":20.51,"max":22.375},"gpu_busy_ms_per_present":5.72,"worker_busy_pct":{"queue worker 0x0":25.322},"phase_totals_ms":{"Driver.Completion":4.606,"Driver.Draw":1103.352,"Driver.Draw.device_setup":60.847,"Driver.Draw.draw_enqueued":166.414,"Driver.Draw.post_compile_prepare":5.042,"Driver.Draw.prepare":162.183,"Driver.Draw.shader_compile_and_link":688.095,"Driver.EndSubmission":10.786,"Driver.Packet":2520.12,"Driver.Packet.device_lock":12.268,"Driver.Packet.draw":1114.525,"Driver.Packet.execute":117.855,"Driver.Packet.flip_flush":80.287,"Driver.Packet.flush_between_packets":25.34,"Driver.Packet.pipeline_drain":1033.953,"Driver.Packet.pipeline_prepare":22.714,"Driver.Packet.prepare_memory":25.067,"Driver.Present":685.783,"Driver.Present.acquire_image":81.77,"Driver.Present.device_setup":1.64,"Driver.Present.gpu_mutex_wait":28.468,"Driver.Present.inflight_wait":5.559,"Driver.Present.present_display_buffer":192.211,"Driver.Present.queue_present":266.594,"Driver.Present.release_and_callback":1.787,"Driver.Present.render_fence_wait":102.398,"Driver.Present.resize":2.948,"Driver.Present.validate":0.908,"Driver.Suspend":0.85,"GpuMutex.wait.draw":4.448,"GpuMutex.wait.end":4.622,"GpuMutex.wait.flush":0.288,"GpuMutex.wait.label":1.06,"GpuMutex.wait.present":24.161,"GpuMutex.wait.wait":91.828,"Graphics.Draw":2707.314,"Graphics.Draw.draw_and_resource_release":2575.438,"Graphics.Draw.index_upload":2.235,"Graphics.Draw.validate":96.073,"Graphics.Draw.vertex_upload":14.498,"Recorder.Reap":119.636,"Recorder.Submit":416.117,"Recorder.Sync":39.308,"Recorder.WaitSerial":22.766,"Resources.Complete":268.193,"Resources.Prepare":350.273,"Shader.DrawStage":588.314,"Shader.DrawStage.capture_resources":408.147,"Shader.DrawStage.materialize":78.085,"Shader.DrawStage.prepared_invocation":95.298,"VideoOut.Flip":1640.189,"VideoOut.Flip.completion_mutex_wait":1.439,"VideoOut.Flip.config_mutex_wait":0.523,"VideoOut.Flip.frame_limit":1.91,"VideoOut.Flip.notify_game":17.825,"VideoOut.Flip.present":692.791,"VideoOut.Flip.validate":2.683,"VideoOut.Flip.vblank_wait":863.104,"VideoOut.Flip.window_prepare":2.525,"VideoOut.Flip.window_title":56.486,"VideoOut.Readiness":4.384,"VideoOut.Readiness.locks_validate":2.019,"Vulkan.Acquire":77.189,"Vulkan.Acquire.acquire_fence_wait":13.495,"Vulkan.Acquire.acquire_image":50.198,"Vulkan.Acquire.fence_reset":12.182,"Vulkan.Acquire.retired_swapchains":0.631,"Vulkan.Present":132.132,"Vulkan.Present.command_record_scale":90.561,"Vulkan.Present.pixel_upload":5.489,"Vulkan.Present.queue_submit":34.151,"Vulkan.QueuePresent":263.242,"Vulkan.QueuePresent.queue_present":261.368,"Vulkan.Retire":100.432,"Vulkan.Retire.wait":82.154},"top_phases_ms_per_frame":{"Graphics.Draw":4.512,"Graphics.Draw.draw_and_resource_release":4.292,"Driver.Packet":4.2,"VideoOut.Flip":2.734,"Driver.Packet.draw":1.858,"Driver.Draw":1.839,"Driver.Packet.pipeline_drain":1.723,"VideoOut.Flip.vblank_wait":1.439},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.draw":10801,"Graphics.Barrier.label-run":11764,"Graphics.Barrier.present-blit":1200,"Graphics.RenderPass":5400,"Graphics.RenderPass.Close.new-batch":5400,"Graphics.RenderPass.Continued":1800},"trace_dropped":false,"trace":"aps5-trace-fd58fa5a0213-57461.json.gz"}
{"commit":"b0e569cdbef8","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10"},"gpu":"NVIDIA GeForce RTX 5060 Laptop GPU","driver":"NVIDIA 615.78.08","os":"Linux 7.2.9-ogc2.1.fc44.x86_64","cpu":"Intel(R) Core(TM) 7 240H","cpu_threads":16,"memory_mib":15672,"title_id":"PPSA99002","title":"ProsperoLight","content_version":"01.000.110","resolution":"3840x2160","window":{"spec":"seconds 15:10","first_present":893,"ms":10016.223},"presents":596,"frame_ms":{"p50":16.709,"p90":18.899,"p99":21.594,"max":25.535},"gpu_busy_ms_per_present":6.185,"worker_busy_pct":{"queue worker 0x0":25.181},"phase_totals_ms":{"Driver.Completion":4.361,"Driver.Draw":1116.121,"Driver.Draw.device_setup":61.137,"Driver.Draw.draw_enqueued":169.335,"Driver.Draw.post_compile_prepare":5.433,"Driver.Draw.prepare":166.521,"Driver.Draw.shader_compile_and_link":691.371,"Driver.EndSubmission":10.902,"Driver.Packet":2506.179,"Driver.Packet.device_lock":11.771,"Driver.Packet.draw":1127.511,"Driver.Packet.execute":116.734,"Driver.Packet.flip_flush":80.261,"Driver.Packet.flush_between_packets":26.01,"Driver.Packet.pipeline_drain":1002.2,"Driver.Packet.pipeline_prepare":22.446,"Driver.Packet.prepare_memory":25.411,"Driver.Present":671.828,"Driver.Present.acquire_image":82.182,"Driver.Present.device_setup":1.619,"Driver.Present.gpu_mutex_wait":24.592,"Driver.Present.inflight_wait":5.903,"Driver.Present.present_display_buffer":195.708,"Driver.Present.queue_present":276.712,"Driver.Present.release_and_callback":1.765,"Driver.Present.render_fence_wait":77.718,"Driver.Present.resize":3.121,"Driver.Present.validate":1.109,"Driver.Suspend":0.743,"GpuMutex.wait.draw":1.793,"GpuMutex.wait.end":1.356,"GpuMutex.wait.flush":0.368,"GpuMutex.wait.label":1.051,"GpuMutex.wait.present":20.263,"GpuMutex.wait.wait":103.203,"Graphics.Draw":2710.267,"Graphics.Draw.draw_and_resource_release":2575.216,"Graphics.Draw.index_upload":2.324,"Graphics.Draw.validate":99.898,"Graphics.Draw.vertex_upload":15.066,"Recorder.Reap":118.061,"Recorder.Submit":423.194,"Recorder.Sync":38.432,"Recorder.WaitSerial":21.564,"Resources.Complete":263.473,"Resources.Prepare":351.209,"Shader.DrawStage":589.455,"Shader.DrawStage.capture_resources":406.719,"Shader.DrawStage.materialize":78.699,"Shader.DrawStage.prepared_invocation":96.904,"VideoOut.Flip":1398.154,"VideoOut.Flip.completion_mutex_wait":1.485,"VideoOut.Flip.config_mutex_wait":0.378,"VideoOut.Flip.frame_limit":1.672,"VideoOut.Flip.notify_game":16.535,"VideoOut.Flip.present":679.536,"VideoOut.Flip.validate":2.665,"VideoOut.Flip.vblank_wait":635.095,"VideoOut.Flip.window_prepare":2.561,"VideoOut.Flip.window_title":57.326,"VideoOut.Readiness":4.4,"VideoOut.Readiness.locks_validate":2.02,"Vulkan.Acquire":77.391,"Vulkan.Acquire.acquire_fence_wait":12.826,"Vulkan.Acquire.acquire_image":50.641,"Vulkan.Acquire.fence_reset":12.529,"Vulkan.Acquire.retired_swapchains":0.697,"Vulkan.Present":134.514,"Vulkan.Present.command_record_scale":92.249,"Vulkan.Present.pixel_upload":5.489,"Vulkan.Present.queue_submit":35.121,"Vulkan.QueuePresent":273.191,"Vulkan.QueuePresent.queue_present":271.087,"Vulkan.Retire":75.681,"Vulkan.Retire.wait":57.749},"top_phases_ms_per_frame":{"Graphics.Draw":4.547,"Graphics.Draw.draw_and_resource_release":4.321,"Driver.Packet":4.205,"VideoOut.Flip":2.346,"Driver.Packet.draw":1.892,"Driver.Draw":1.873,"Driver.Packet.pipeline_drain":1.682,"Driver.Draw.shader_compile_and_link":1.16},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.draw":10727,"Graphics.Barrier.label-run":11672,"Graphics.Barrier.present-blit":1192,"Graphics.RenderPass":5363,"Graphics.RenderPass.Close.new-batch":5363,"Graphics.RenderPass.Continued":1788},"trace_dropped":false,"trace":"aps5-trace-b0e569cdbef8-61961.json.gz"}

Upstream assessment after the batch: later main 2454441420d5 changes shader lowering and AGC resources. All ten retained NVIDIA shader inputs emit byte-identical SPIR-V, and five focused regression tests pass on Radeon. This is bounded compatibility evidence, not a timing measurement of later main; the results above remain tied to the exact fd58fa5a0213-based binaries.

Earlier evidence, attributed to its original revisions:

Review follow-up (2026-11-12), head dec8809c5f2e: integrated main 3b7f31fa700b and bounded the shared LogicalAnd search in RegionNanCondition with an explicit work stack and visited set. It preserves the original left-to-right first-match result and avoids recursive stack growth. The unchanged #17681/main integration 6cfe0feaee34 reproduces the reported agc_shader_memory timeout at 30 s. The existing full test now passes in about 2.96–2.97 s on main and all three repaired heads (#17681, #17709 and #17919).

The same seven tests pass on main and each repaired head: agc_shader_memory, agc_spirv_branch_targets, agc_denormal_flush_elimination, agc_driver_f32_arithmetic_nan, agc_driver_f32_arithmetic_nan_fast, agc_driver_f32_min_max_nan and agc_driver_nan_quieting. Radeon 760M / RADV Mesa 25.0.7-2+deb13u1 / Debian 13 / Linux 7.3.3-x64v3-xanmod1 / GCC 15.2.0 Release; required Vulkan/cache environment, VK_LOADER_DEBUG=layer, validation layer 1.4.363. Every arm has four actual instance/device layer insertions, zero skips, no missing-layer messages and no VUID errors. Three retained requests emit byte-identical SPIR-V before/after the traversal fix at the #17681 integration; the output comparison is limited to those requests.

The following historical FPS and trace results retain their original measured revisions. The November 12 repair heads were not gameplay-retimed. Current-head NVIDIA author measurements are above; no new Radeon gameplay or cold-pipeline improvement is claimed. Reviewer acceptance remains separate.

Independent fixed-head evidence: Doorriiaann's RTX 3070 rerun reports all 113 tests passing twice on merge-base 0dd2fffe35 and head 180bfe87a5, with NVIDIA 610.57.04, GCC 13.3.0 Release and no VUID or synchronization-hazard lines. talha-devp's Windows/RTX 4060 comparison integrates the fixed head onto main ae921fe200 as 588a59f1c9, against #17681 control e9b864c98d. ProsperoLight's 4K idle screen reports warm GPU time of 12.19 / 11.66 ms versus 12.19 / 12.21 ms; two windows do not separate the incremental difference from noise. The slowest cold pipeline takes 5.41 s versus 4.14 s, one run each: an unresolved cold-creation concern, not a demonstrated improvement. The dominant program shrinks by 2,383 SPIR-V words and 99 selects. Focused tests pass on all four reported arms with Khronos validation and no VUID lines. These are the contributors' measurements on their stated revisions, separate from our Radeon cohort; they do not retime current main.

Review follow-up at 180bfe87a5: the unchanged prefix before the first bypassed NaN repair is emitted once before the branch. Both paths reuse it, including the required input denormal flush; the existing chained-multiply regression retains its original one-mask assertion. The performance measurements below belong to their stated earlier revisions and have not been repeated for this fix.

Radeon 760M, RADV Mesa 25.0.7, Ryzen 5 7640HS, Linux 7.3.3-x64v3-xanmod1, GCC Release, production GPL/LTO. Frozen prerequisite control 15be56b2a99c877dbe4ebf60e1ed1b0ec3b18559 versus follow-up 9ece702ba44b11fbdc70bb0b6e9f5261a13c3911. The shared source files remain unchanged between frozen main 0dd2fffe3576 and refreshed main ca761cadc5ba; timings belong to the named control/candidate revisions.

The emission regression fails on the prerequisite and passes with this change; the unproved-condition negative keeps both selections. The same four focused arithmetic/NaN/Fract/trig fixtures pass on main, prerequisite and final candidate, with actual Khronos device-layer insertions and no VUID or missing-layer errors. A retained dependent synthetic chain produces 24,864 bit-identical bytes over 24 dispatches per arm, covering mixed/uniform signaling NaNs, source priority, finite overflow followed by invalid operations, IEEE 0/1, denormal modes 0/3 and signed neighboring encodings around two entry thresholds.

Exactly two ordinary pairs, prospectively fixed ABBA, all four valid, no replacements or extra pairs:

Pair Prerequisite FPS Follow-up FPS Paired change
1 29.526068 31.008252 +5.019915%
2 29.549603 31.016971 +4.965776%

Mean paired change +4.992846%, 95% Student-t interval with one degree of freedom [+4.648896%, +5.336795%]. Two run-level pairs remain a small sample despite the narrow observed interval. This is an incremental warmed stationary 4K camp result on one machine, with no broad gameplay, hitch, cross-engine or second-scene claim. It is not added to the separate #17681 result.

Both arms used the same visible MangoHud observer, 1280x720 X11 client, requested Immediate presentation, dummy audio, unchanged guest cap and owned warmed save/cache copies. Excluded preparations witnessed 3840x2160 rendering calls. All timed windows retained focus, camp and unchanged caches; all 63 loaded modules matched except AGC, and reported clocks stayed 2,599 MHz. No builds, profiler, debugger, screenshots or input during ordinary windows.

Audited evidence: four interval CSVs, frozen protocol, provenance, hardware/native counts and original scoped timing/count traces. All 23 uploaded files were verified once byte for byte; exported FPS and the three original gzip payloads reproduce. Include the first exported interval in FPS calculations. Private shaders, IR, ISA, hardware captures, screenshots, saves and console logs are excluded.

The required summaries below are separate eight-second normal diagnostics, not ordinary FPS replicates. GPU command span is 30.099 → 29.021 ms/present for prerequisite versus follow-up. Retained main is 32.982 ms/present on the same machine and scene; it is attached to satisfy the repository's main/change trace requirement, not to infer a combined ordinary FPS effect. All traces have stable caches and zero dropped events. The resolution field is API metadata.

Frozen main:

{"commit":"0dd2fffe3576","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_OUTPUT_RESOLUTION":"3840x2160","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_BENCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"524288","APS5_TRACE_SECONDS":"40:8","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.3.3-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 40:8","first_present":1146,"ms":8010.275},"presents":224,"frame_ms":{"p50":35.674,"p90":36.334,"p99":37.177,"max":37.55},"gpu_busy_ms_per_present":32.982,"worker_busy_pct":{"queue worker 0x0":78.242},"top_phases_ms_per_frame":{"Driver.Packet":27.876,"Driver.Packet.draw":25.409,"Driver.Draw":25.372,"Driver.Draw.draw_enqueued":21.84,"Recorder.Sync":20.661,"VideoOut.Flip":7.257,"VideoOut.Flip.present":7.191,"Driver.Present":7.177},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-0dd2fffe3576-31569.json.gz"}

Prerequisite control:

{"commit":"15be56b2a99c","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_OUTPUT_RESOLUTION":"3840x2160","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_BENCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"524288","APS5_TRACE_SECONDS":"40:8","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.3.3-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 40:8","first_present":1190,"ms":8009.591},"presents":244,"frame_ms":{"p50":32.881,"p90":33.484,"p99":34.338,"max":34.684},"gpu_busy_ms_per_present":30.099,"worker_busy_pct":{"queue worker 0x0":77.854},"top_phases_ms_per_frame":{"Driver.Packet":25.45,"Driver.Packet.draw":22.959,"Driver.Draw":22.921,"Driver.Draw.draw_enqueued":19.365,"Recorder.Sync":18.18,"VideoOut.Flip":6.568,"VideoOut.Flip.present":6.504,"Driver.Present":6.491},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-15be56b2a99c-80159.json.gz"}

Follow-up:

{"commit":"9ece702ba44b","dirty":false,"env":{"APS5_NO_PAD_INPUT":"1","APS5_OUTPUT_RESOLUTION":"3840x2160","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_BENCH":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"524288","APS5_TRACE_SECONDS":"40:8","APS5_TRACE_SUMMARY_EVERY":"1"},"gpu":"AMD Radeon 760M (RADV PHOENIX)","driver":"radv Mesa 25.0.7-2+deb13u1","os":"Linux 7.3.3-x64v3-xanmod1","cpu":"AMD Ryzen 5 7640HS w/ Radeon 760M Graphics","cpu_threads":12,"memory_mib":23820,"title_id":"PPSA28997","title":"God of War Sons of Sparta","content_version":"01.008.001","resolution":"1920x1080","window":{"spec":"seconds 40:8","first_present":1213,"ms":8023.167},"presents":252,"frame_ms":{"p50":31.674,"p90":32.507,"p99":34.138,"max":35.4},"gpu_busy_ms_per_present":29.021,"worker_busy_pct":{"queue worker 0x0":78.218},"top_phases_ms_per_frame":{"Driver.Packet":24.792,"Driver.Packet.draw":22.112,"Driver.Draw":22.072,"Driver.Draw.draw_enqueued":18.162,"Recorder.Sync":16.842,"VideoOut.Flip":6.5,"VideoOut.Flip.present":6.422,"Driver.Present":6.409},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-9ece702ba44b-116533.json.gz"}

Independent later-title report: @klosixgaming-arch's Cyberpunk 2077 intro check used this head b0e569cdbe merged onto main e4caa07950 as ad0d1a17d9, Ubuntu 26.04.1 / Linux 7.0.0-43, NVIDIA RTX 2080 Ti / 595.99.02, GCC 15.2 Release, PPSA03974 02.120.000. They report no measurable warm intro difference (50.1 vs 50.2 presents per 10 seconds, base vs PR), from three base boots and two warm PR boots. Their separate first PR boot rebuilt 1,420 cache entries and stalled; it is retained in their report as cold-cache preparation. No driver failure, abort, or NotImplemented was reported. These are their observations, not author-run timing or validation-layer evidence, and are separate from the existing cold-pipeline diagnostics and the Sons of Sparta results.

Checklist

  • Based on current main; no other open PR implements the same functions — fd58fa5a0213 pinned before validation; subsequent upstream assessment above
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: perf(shader): guard NaN repair regions using certified inputs #17681
  • Fixes: none
  • Unblocks: none
  • GPUs tested: author current-head runs: NVIDIA GeForce RTX 5060 Laptop GPU, NVIDIA 615.78.08, Bazzite 44 / Linux 7.2.9; AMD Radeon 760M, RADV Mesa 25.0.7-2+deb13u1, Linux 7.3.3-x64v3-xanmod1; independent reports: NVIDIA GeForce RTX 3070, NVIDIA 610.57.04, Debian 13; NVIDIA GeForce RTX 4060, NVIDIA 621.14, Windows 10 19045; independent Cyberpunk game report: NVIDIA GeForce RTX 2080 Ti, NVIDIA 595.99.02, Ubuntu 26.04.1 / Linux 7.0.0-43 (exact earlier main/merge and limitations above)
  • AI-assisted: yes

@github-actions github-actions Bot added the perf Performance change label Nov 9, 2026
@oneandonlydean oneandonlydean self-assigned this Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6416 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 6751 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 7392 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 7642 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 9508 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 10193 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 13928 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 13929 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 14217 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 14218 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 16952 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp
PR 18530 core/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp

@Doorriiaann

Copy link
Copy Markdown
Contributor

This includes #17681's 15be56b2a9, so it carries the agc_denormal_flush_elimination failure I reported there (#17681 (comment)). Same run on this head 9ece702ba4 (NVIDIA RTX 3070, 610.57.04, GCC 13.3.0 Release, the same 113 tests, 2 runs per commit, validation layer vulkan-sdk-1.4.335.0):

merge-base 0dd2fffe35 this PR 9ece702ba4
agc_denormal_flush_elimination passed 2/2 failed 2/2 (2 f32 exponent masks, expected 1 in "two chained v_mul_f32 keep only the input flush of the first source")
the other 112 tests 224/224 passed 224/224 passed

No VUID- or SYNC-HAZARD- line in any run. The test does not use the GPU, so a fix in #17681 should clear it here too once this is rebased.

AI-assisted: yes (run and drafted with an AI agent, checked by me)

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @Filip722, thanks for the detailed evidence. I read the region guard and the new certified-condition reuse, and the bound reasoning looks sound to me.

One existing test fails on this head, though. Release build of 9ece702ba44b, Linux:

agc_denormal_flush_elimination
  2 f32 exponent masks, expected 1
two chained v_mul_f32 keep only the input flush of the first source

(core/libs/prx/libSceAgcDriver/tests/DenormalFlushElimination.cpp lines 423-433.) agc_spirv_branch_targets passes. This confirms what Doorriiaann reported above and on #17681: the test fails from 15be56b2a9 and passes on 0dd2fffe35 and 94856d4feb, so it comes from the prerequisite commit included here, not from 9ece702ba44b itself. The test only counts the emitted SPIR-V, so it fails on every platform. The Windows job ran a single selected test, which is why CI is green.

My guess is that the region now emits the two multiplies twice (fast path and exact fallback), each with its own input flush. Could you either keep the flush down to one mask for this shader, or, if each path keeps the elimination, show that and update the expectation with the reason? Once it passes I'll rerun the float GPU tests on the new head.

@Filip722

Filip722 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@Doorriiaann Carried the #17681 prefix fix into this branch as 180bfe87a5, without rewriting either branch's history. The unchanged common prefix is emitted once, so the existing chained-multiply regression again sees one input-flush exponent mask.

Matched frozen main 0dd2fffe35 and this repaired head selected the same 113 float/NaN/denormal/trig and branch-target tests: 112 passed per arm, with the same agc_driver_float16_unused_nan_payloads capability skip. Radeon 760M / RADV Mesa 25.0.7, Khronos instance/device layers loaded in 102 tests per arm; no missing-layer messages or VUID errors. Your NVIDIA run remains separate evidence.

The incremental timings remain attributed to the revisions originally measured; this correction has not been retimed. Depends on #17681 remains unchanged.

AI-assisted: yes (Codex).

@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Nov 9, 2026
@Filip722

Filip722 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@oneandonlydean The first option is implemented in 180bfe87a5: emit the unchanged prefix, including the first input flush, once before branching around the repair suffix. The existing one-mask expectation passes unchanged; it was not relaxed. This is the same fix as #17681's 8d1a3d6e48.

The matched Radeon results cover all 113 selected float/NaN/denormal/trig and branch-target tests (112 pass, the same one float16 capability skip as tested main; actual Khronos layers, zero VUIDs). The current Windows and relinker checks also pass. The correction remains unretimed; the description keeps the earlier incremental measurements on their exact revisions. The fixed head is available for your requested GPU rerun.

AI-assisted: yes (Codex).

@Doorriiaann

Copy link
Copy Markdown
Contributor

NVIDIA on the fixed head 180bfe87a5, same 113 tests and command as above (RTX 3070, 610.57.04, GCC 13.3.0 Release, 2 runs per commit): merge-base 0dd2fffe35 226/226 passed, 180bfe87a5 226/226 passed, including agc_denormal_flush_elimination (2/2) and agc_spirv_branch_targets. No VUID- or SYNC-HAZARD- line in any run.

AI-assisted: yes

@talha-devp

Copy link
Copy Markdown
Contributor

@oneandonlydean @Filip722 GPU rerun of the fixed head 180bfe87a5 on NVIDIA, against its prerequisite #17681 (8d1a3d6e48).

Setup. RTX 4060, driver 621.14, Windows 10 19045, Ryzen 5 5600, MSYS2 GCC 16.2.0 Release. Four local builds:

Title. ProsperoLight (PPSA99002 01.000.110), idle screen, 3840x2160.

Method. One round per build in the order above.

  • Cold. A 25 s run, read from the pipeline= field of APS5_PROFILE_DRAW.
  • Warm. --runs 3 --seconds 40 with APS5_TRACE_SECONDS=15:10, with run 1 dropped: 2 windows per build.
main #17681 this PR this PR + #17227
0x217e15000 SPIR-V words (agc_shader_replay) 258,825 482,809 480,426 369,337
OpSelect in it 11,825 19,679 19,580 12,630
GPU busy per present, warm (2 windows) 17.18 / 17.46 ms 12.19 / 12.21 ms 12.19 / 11.66 ms 8.86 / 8.87 ms
slowest pipeline creation, cold run 2.02 s 4.14 s 5.41 s 3.30 s

Results.

Summary lines, #17681 and this PR, first warm window
{"commit":"e9b864c98dc9","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4060","driver":"NVIDIA 621.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":32678,"title_id":"PPSA99002","title":"ProsperoLight","content_version":"01.000.110","resolution":"3840x2160","window":{"spec":"seconds 15:10","first_present":895,"ms":10010.005},"presents":600,"frame_ms":{"p50":16.684,"p90":16.936,"p99":17.779,"max":21.239},"gpu_busy_ms_per_present":12.19,"worker_busy_pct":{"queue worker 0x0":13.41},"top_phases_ms_per_frame":{"Driver.Packet":2.182,"Graphics.Draw":1.957,"Graphics.Draw.draw_and_resource_release":1.904,"VideoOut.Flip":1.629,"VideoOut.Flip.vblank_wait":0.992,"Driver.Packet.pipeline_drain":0.702,"Driver.Packet.draw":0.629,"Driver.Draw":0.623},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-e9b864c98dc9-19936.json.gz"}
{"commit":"588a59f1c931","dirty":false,"env":{"APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"15:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4060","driver":"NVIDIA 621.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":32678,"title_id":"PPSA99002","title":"ProsperoLight","content_version":"01.000.110","resolution":"3840x2160","window":{"spec":"seconds 15:10","first_present":897,"ms":10009.989},"presents":600,"frame_ms":{"p50":16.684,"p90":17.08,"p99":17.943,"max":18.696},"gpu_busy_ms_per_present":12.192,"worker_busy_pct":{"queue worker 0x0":13.861},"top_phases_ms_per_frame":{"Driver.Packet":2.266,"Graphics.Draw":2.047,"Graphics.Draw.draw_and_resource_release":1.993,"VideoOut.Flip":1.511,"VideoOut.Flip.vblank_wait":0.84,"Driver.Packet.pipeline_drain":0.715,"Driver.Packet.draw":0.657,"Driver.Draw":0.651},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-588a59f1c931-16616.json.gz"}

AI-assisted: yes. Claude Code ran the builds, tests and runs and drafted this comment.

@JJenkx

JJenkx commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Windows GPU check of head 180bfe87a5, merged onto main 651eb9a25e (27294b4c15, clean merge). Run through the Windows FIFO, job c80e0b57303344f3bd3023321ebce4da, exit 0 with cleanup verified.

Setup: Windows 11 Enterprise 22621, AMD Radeon RX 6700 XT (driver 32.0.21045.16010), WinLibs GCC 15.2 UCRT, Release, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1.

These three tests pass in 3 of 3 runs each, 9 of 9, none skipped:

  • agc_driver_f32_arithmetic_nan
  • agc_driver_f32_arithmetic_nan_fast
  • agc_spirv_branch_targets

All 409 test and .prx hashes matched the prepared build when the job started.

AI-assisted: yes.

@Filip722

Copy link
Copy Markdown
Contributor Author

@talha-devp I added your fixed-head four-arm report to the description, including the inconclusive warm comparison against #17681 and the 5.41 versus 4.14 s cold-pipeline result (one run each). The cold-creation concern remains open. I cannot reproduce that ProsperoLight/NVIDIA case with the corpus and Radeon host available locally, so I have no contrary measurement or cold-cost fix to claim.

@Doorriiaann Your 113-test, two-run verification of 180bfe87a5 is now linked separately. The denormal regression keeps its original one-mask assertion; the existing fix and branch head are unchanged. Historical Radeon timings remain on their measured revisions.

AI-assisted: yes (Codex).

@Filip722

Copy link
Copy Markdown
Contributor Author

Carried the prerequisite RegionNanCondition hang fix into this branch as dec8809c5f2e, with main 3b7f31fa700b integrated and history preserved. The shared-DAG walk is bounded; the reported verifyHalfWaveReduction path completes through the existing full shader-memory test.

The same seven focused tests pass on main 3b7f31fa700b and all three repaired heads, including the full agc_shader_memory, branch-target and denormal regressions, exact/fast arithmetic, min/max and quieting. Radeon 760M / RADV Mesa 25.0.7 / Debian 13 / GCC 15.2 Release, Khronos 1.4.363: four actual layer insertions per arm, zero skips, missing-layer messages or VUIDs. agc_shader_memory is 2.96–2.97 s in all four runs.

The description records these exact revisions. Existing gameplay timings/traces remain attached to their original commits; these heads have not been gameplay-retimed.

AI-assisted: yes (Codex).

The separately reported ProsperoLight/NVIDIA cold-pipeline cost remains open; this CPU traversal repair does not claim to fix that driver-compilation result.

@Filip722

Filip722 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

@talha-devp Completed the requested second look on your ProsperoLight version/4K idle scene, using the RTX 5060 laptop (NVIDIA 615.78.08/Bazzite). Main fd58fa5a0213 is integrated; measured head is b0e569cdbef8.

Two cold starts give longest draw pipeline phases of 1.741/1.743 s here versus 1.743/1.735 s on #17681 and 1.218/1.161 s on main. This Linux setup does not reproduce an extra #17709-over-#17681 penalty; the shared cold penalty versus main remains. These are draw-phase diagnostics, not isolated Vulkan-call durations.

Warm GPU span: this PR 6.185 / 6.170 ms, #17681 6.342 / 6.356 ms, main 5.720 / 6.032 ms, two fixed windows each at the 60 Hz cap. The same 15 tests pass on main/head on both Radeon 760M and RTX 5060 with actual Khronos 1.4.363 insertion, zero VUIDs/skips. The current-main definition-table build fix is included. Your Windows measurements remain separately attributed; this does not mark the tradeoff resolved.

Both warm spans are higher than main; with only two pairs the interval crosses zero, so no improvement is established. The shared batch spans a reboot: six valid original windows were retained, two unusable attempts replaced, and four windows completed after restart; no extra pairs.

Upstream assessment after the batch: later main 2454441420d5 changes shader lowering and AGC resources. All ten retained NVIDIA shader inputs emit byte-identical SPIR-V, and five focused regression tests pass on Radeon. This is bounded compatibility evidence, not a timing measurement of later main; the results above remain tied to the exact fd58fa5a0213-based binaries.

Hosted CI for this exact head passed, including Windows, all three relinkers, ASan and conventions; the conditional full Linux job was skipped. The matched local/remote device runs above are the hardware-validation evidence.

Audited evidence, all traces/digests, exact revisions and limitations. Descriptions updated. AI-assisted: yes (Codex).

@klosixgaming-arch

Copy link
Copy Markdown
Contributor

Tested on Cyberpunk 2077 on Linux. No measurable difference in the intro once the shader cache is warm. The first PR boot was slow only because this PR changes the shader output, so that boot compiled everything again.

Setup: Ubuntu 26.04.1 (Linux 7.0.0-43), NVIDIA GeForce RTX 2080 Ti (595.99.02), Xeon E5-2699 v3, GCC 15.2.0 Release. Base: main e4caa07950 (it includes #19071). This PR's head b0e569cdbe merged on top (ad0d1a17d9, clean merge), built in a separate tree. Cyberpunk 2077 PPSA03974 02.120.000, intro movie, no input, warm shader caches. Boots alternate base and PR, three each; each number is the mean of the 10 s summary windows from 40 s to 160 s.

boot build presents per 10 s, windows 40 s to 160 s mean
1 base 49 49 47 49 49 47 49 49 47 48 48 48.3
2 this PR 34 7 14 51 53 51 53 37.6
3 base 55 51 54 54 51 53 53 53 53 50 48 52.3
4 this PR 53 50 53 51 47 50 51 50 51 51 52 50.8
5 base 51 48 51 52 48 50 50 50 50 48 49 49.7
6 this PR 50 49 50 50 47 50 50 49 50 50 50 49.5
  • The first PR boot rebuilt the shader disk cache, because the shader source version changes with this PR: 1,420 misses and 1.36 GB written in its first window. It stalled until about 110 s and ran at 51 to 53 after that. I leave it out as a cold-cache boot, not a slowdown.
  • Warm boots: base 50.1 on average (48.3 to 52.3), this PR 50.2 (49.5 to 50.8): no difference. That is only two warm PR boots against three base boots.
  • No driver failure, abort or NotImplemented line in any of the six boots.

@Filip722

Copy link
Copy Markdown
Contributor Author

@klosixgaming-arch Added your separately attributed Cyberpunk report and exact main/merge revisions to the description. It records no measurable warm intro gain, the unequal three-base/two-warm-PR boot counts, and the separate cache-rebuild boot. Your results remain distinct from the existing pipeline-creation diagnostics and our other-title timings.

AI-assisted: yes (Codex).

@oneandonlydean
oneandonlydean merged commit 22317b7 into boykopovar:main Nov 17, 2026
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* perf Performance change shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants